cmake_minimum_required(VERSION 2.6)
project(Realmd)

include_directories(
    ${PROJECT_SOURCE_DIR}
)

set(RealmdSRC
    RealmdApplication.h
    RealmdApplication.cc
    ErrorHandler.cc
    GlobalVars.h
    GlobalVars.cc
    Main.cc
    RealmList.h
    RealmList.cc
)

set(Realmd_Auth_SRC
    Auth/AuthSocketDelegate.h
    Auth/AuthSocketDelegate.cc
    Auth/AuthSocketDelegateFactory.h
    Auth/AuthSession.h
    Auth/AuthSession.cc
    Auth/AuthSessionManager.h
    Auth/AuthSessionManager.cc
)

if (WIN32)
    set(RealmdSRC Realmd.rc ${RealmdSRC})
endif()

if (MSVC)
    source_group("Auth" FILES ${Realmd_Auth_SRC})
endif()

add_executable(Realmd 
    ${RealmdSRC}
    ${Realmd_Auth_SRC}
)
target_link_libraries(Realmd
    Shared
    NodeCpp
    tinyxml
    ${LIBEVENT_LIBRARY}
    ${OPENSSL_LIBRARY}
    ${MYSQL_LIBRARY}
)

if (WIN32)
target_link_libraries(Realmd ws2_32 dbghelp)
elseif(UNIX)
target_link_libraries(Realmd pthread)
endif()

add_custom_command(TARGET Realmd
    POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/Realmd.conf ${PROJECT_BINARY_DIR}/
)